﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class GridPageSort : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
    {
        gvProduct.PageSize = int.Parse(ddlPageSize.SelectedValue);
        gvProduct.DataBind();

    }

    protected void gvProduct_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //方法1，字符串的拼接
        lbMsg.Text = "当前页为第" + (gvProduct.PageIndex + 1).ToString()
            + "页，共有" + gvProduct.PageCount.ToString() + "页";
        //方法2，string.Format方法
        lbMsg.Text = string.Format("当前页为第{0},共有{1}页", gvProduct.PageIndex + 1, gvProduct.PageCount);
    }
}